/**App包裹组件:https://ant-design.antgroup.com/components/app-cn
 * 用于封装全局的 message、Modal.xxx、notification.xxx 的静态方法，
 *
 */
import { App } from 'antd';
import type { MessageInstance } from 'antd/es/message/interface';
import type { ModalStaticFunctions } from 'antd/es/modal/confirm';
import type { NotificationInstance } from 'antd/es/notification/interface';

let message: MessageInstance;
let notification: NotificationInstance;
let modal: Omit<ModalStaticFunctions, 'warn'>;

/**
 * 全局Ant Design组件初始化函数
 * 作用: 初始化全局的message、Modal.xxx、notification.xxx 的静态方法
 * @returns 无返回值
 */
const AntdGlobal = () => {
    const staticFunction = App.useApp();
    message = staticFunction.message;
    modal = staticFunction.modal;
    notification = staticFunction.notification;
    return null;
};
export default AntdGlobal;

// eslint-disable-next-line react-refresh/only-export-components
export { message, notification, modal };
